package cn.javaxc.mvcwork.modules.admin;
import cn.javaxc.mvcwork.framework.beans.TFormBean;
import cn.javaxc.model.base.*;
import cn.javaxc.mvcwork.util.common.*;
import java.sql.*;
import javax.servlet.http.HttpServletRequest;




class Permission extends TFormBean {

  private static final long serialVersionUID = 2044602526197322790L;

  protected int id = -1;
  protected int categoryId = -1;
  protected String categoryName = null;
  protected int permissionLevel = -1;
  protected String name = null;
  protected boolean add = false;
  protected boolean view = false;
  protected boolean edit = false;
  protected boolean delete = false;
  protected String description = null;
  protected boolean enabled = false;
  protected boolean active = true;
  protected boolean viewpoints = false;


  private Timestamp entered = null;
  private Timestamp modified = null;
	private String sid;

  
  public Permission() {
  }


  
  public Permission(SQLMap rs){
    buildRecord(rs);
  }


 
  
  public void setId(int tmp) {
    this.id = tmp;
  }


  
  public void setId(String tmp) {
    this.id = Integer.parseInt(tmp);
  }


  
  public void setCategoryId(int tmp) {
    this.categoryId = tmp;
  }


  
  public void setCategoryId(String tmp) {
    this.categoryId = Integer.parseInt(tmp);
  }


  
  public void setCategoryName(String tmp) {
    this.categoryName = tmp;
  }


  
  public void setPermissionLevel(int tmp) {
    this.permissionLevel = tmp;
  }


  
  public void setPermissionLevel(String tmp) {
    this.permissionLevel = Integer.parseInt(tmp);
  }


  
  public void setName(String tmp) {
    this.name = tmp;
  }


  
  public void setAdd(boolean tmp) {
    this.add = tmp;
  }


  
  public void setAdd(String tmp) {
    this.add = DatabaseUtils.parseBoolean(tmp);
  }


  
  public void setView(boolean tmp) {
    this.view = tmp;
  }


  
  public void setView(String tmp) {
    this.view = DatabaseUtils.parseBoolean(tmp);
  }


  
  public void setEdit(boolean tmp) {
    this.edit = tmp;
  }


  
  public void setEdit(String tmp) {
    this.edit = DatabaseUtils.parseBoolean(tmp);
  }


  
  public void setDelete(boolean tmp) {
    this.delete = tmp;
  }


  
  public void setDelete(String tmp) {
    this.delete = DatabaseUtils.parseBoolean(tmp);
  }


  
  public void setDescription(String tmp) {
    this.description = tmp;
  }


  
  public void setEnabled(boolean tmp) {
    this.enabled = tmp;
  }


  
  public void setEnabled(String tmp) {
    this.enabled = DatabaseUtils.parseBoolean(tmp);
  }


  
  public void setActive(boolean tmp) {
    this.active = tmp;
  }


  
  public void setActive(String tmp) {
    this.active = DatabaseUtils.parseBoolean(tmp);
  }


  
  public void setViewpoints(boolean tmp) {
    this.viewpoints = tmp;
  }


  
  public void setViewpoints(String tmp) {
    this.viewpoints = DatabaseUtils.parseBoolean(tmp);
  }


  
  public int getId() {
    return id;
  }


  
  public int getCategoryId() {
    return categoryId;
  }


  
  public String getCategoryName() {
    return categoryName;
  }


  
  public int getPermissionLevel() {
    return permissionLevel;
  }


  
  public String getName() {
    return name;
  }


  
  public boolean getAdd() {
    if (enabled) {
      return add;
    } else {
      return false;
    }
  }


  
  public boolean getView() {
    if (enabled) {
      return view;
    } else {
      return false;
    }
  }


  
  public boolean getEdit() {
    if (enabled) {
      return edit;
    } else {
      return false;
    }
  }


  
  public boolean getDelete() {
    if (enabled) {
      return delete;
    } else {
      return false;
    }
  }


  
  public String getDescription() {
    return description;
  }


  
  public boolean getEnabled() {
    return enabled;
  }


  
  public boolean getActive() {
    return active;
  }


  
  public boolean getViewpoints() {
    return viewpoints;
  }



  
  public Timestamp getEntered() {
    return entered;
  }

  
  public void setEntered(Timestamp entered) {
    this.entered = entered;
  }

  
  public void setEntered(String entered) {
    this.entered = DateUtils.parseTimestampString(entered);
  }

  
  public Timestamp getModified() {
    return modified;
  }


  
  public void setModified(Timestamp modified) {
    this.modified = modified;
  }

  
  public void setModified(String modified) {
    this.modified = DateUtils.parseTimestampString(modified);
  }

  
  protected void buildRecord(SQLMap rs) {
    //permission table
    id = rs.getInt("permission_id");
    categoryId = rs.getInt("category_id");
    name = rs.getString("permission");
    view = rs.getBoolean("permission_view");
    add = rs.getBoolean("permission_add");
    edit = rs.getBoolean("permission_edit");
    delete = rs.getBoolean("permission_delete");
    description = rs.getString("description");
    enabled = rs.getBoolean("enabled");
    active = rs.getBoolean("active");
    viewpoints = rs.getBoolean("viewpoints");

    //permission_category table
    categoryName = rs.getString("category");
    permissionLevel = rs.getInt("level");
    
    entered = rs.getTimestamp("entered");
    modified = rs.getTimestamp("modified");
	sid = rs.getString("sid");
  }



}
